﻿
using System;
namespace ResourceReportBuilder
{
    public class TypeReference : IComparable
    {
        public string Namespace { get; set; }
        public string Name { get; set; }
        public string ID { get; private set; }
        public string Filename { get; set; }

        public TypeReference(string ns, string name)
        {
            Namespace = ns;
            Name = name;
            ID = string.IsNullOrWhiteSpace(Namespace) ? Name : string.Format("{0}.{1}", Namespace, Name);
        }

        public override string ToString()
        {
            return ID;
        }

        public override bool Equals(object obj)
        {
            if (!(obj is TypeReference)) { return false; }
            return this.ToString().Equals((obj is TypeReference).ToString());
        }

        public int CompareTo(object obj)
        {
            TypeReference tr = obj as TypeReference;
            
            if (tr == null) { return -1; }

            return this.ID.CompareTo(tr.ID);
        }
    }
}
